﻿#if false
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using ArgusLib.FFmpeg.avutil;

namespace ArgusLib.FFmpeg
{
	public class LogException : Exception
	{
		public bool Handled { get; set; }

		public LogException(string message, Exception innerException)
			: base(message, innerException)
		{
			this.Handled = false;
		}

		public LogException(string message)
			: this(message, null) { }
	}

	public static class Log
	{
		static avutil.Interop.Delegates.av_log_callback logCallbackDelegate;

		public delegate void ExceptionHandler(LogException e);

		public static event ExceptionHandler ExceptionReceived;

		static Log()
		{
			Log.LogLevel = AVLogLevels.AV_LOG_WARNING;
			Log.logCallbackDelegate = new avutil.Interop.Delegates.av_log_callback(Log.LogCallback);
			avutil.Interop.Functions.av_log_set_callback(Log.logCallbackDelegate);
		}

		public static void Initialize() { }

		private static void LogCallback(IntPtr avcl, AVLogLevels level, string fmt, ArgIterator vl)
		{
			if (level > Log.LogLevel)
				return;
			//object[] args = new object[vl.GetRemainingCount()];
			//while (vl.GetRemainingCount() > 0)
			//{
			//	args[args.Length - vl.GetRemainingCount()] = TypedReference.ToObject(vl.GetNextArg());
			//}

			//string message = String.Format(fmt, args);
			string message = fmt;
			LogException exception = new LogException(message);
			if (Log.ExceptionReceived != null)
				Log.ExceptionReceived(exception);

			if (exception.Handled == false)
				throw exception;
		}

		public static AVLogLevels LogLevel
		{
			get { return avutil.Interop.Functions.av_log_get_level(); }
			set { avutil.Interop.Functions.av_log_set_level(value); }
		}
	}
}
#endif